# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This will parse a textual representation of a duration. The formats
# accepted are based on the ISO-8601 duration format {@code PnDTnHnMn.nS}
# with days considered to be exactly 24 hours.
# <p>
# Examples:
# <pre>
#    "PT20.345S" -- parses as "20.345 seconds"
#    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
#    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
#    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
#    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
#    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
#    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
#    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
# </pre>
filter: "{ tags -> tags.job_name == 'activemq-monitoring' }" # The OpenTelemetry job name
expSuffix: tag({tags -> tags.cluster = 'activemq::' + tags.cluster}).endpoint(['cluster'], ['destinationName'], Layer.ACTIVEMQ)
metricPrefix: meter_activemq_destination
metricsRules:
  # Number of producers attached to this destination.
  - name: producer_count
    exp: org_apache_activemq_Broker_ProducerCount.sum(['cluster','destinationName','destinationType'])
  # Number of consumers subscribed to this destination.
  - name: consumer_count
    exp: org_apache_activemq_Broker_ConsumerCount.sum(['cluster','destinationName','destinationType'])
  # Number of consumers subscribed to the topics.
  - name: topic_consumer_count
    exp: org_apache_activemq_Broker_ConsumerCount.tagEqual('destinationType','Topic').sum(['cluster','destinationName'])
  # The number of messages that have not been acknowledged by a consumer.
  - name: queue_size
    exp: org_apache_activemq_Broker_QueueSize.sum(['cluster','destinationName','destinationType'])
  # Percentage of configured memory used by the destination.
  - name: memory_usage
    exp: org_apache_activemq_Broker_MemoryUsageByteCount.sum(['cluster','destinationName','destinationType'])
  # Percentage of configured memory used by the destination.
  - name: memory_percent_usage
    exp: org_apache_activemq_Broker_MemoryPercentUsage.sum(['cluster','destinationName','destinationType'])
  # The number of messages sent to the destination.
  - name: enqueue_count
    exp: org_apache_activemq_Broker_EnqueueCount.sum(['cluster','destinationName','destinationType'])
  # The number of messages the destination has delivered to consumers.
  - name: dequeue_count
    exp: org_apache_activemq_Broker_DequeueCount.sum(['cluster','destinationName','destinationType'])
  # The average time a message was held on this destination.
  - name: average_enqueue_time
    exp: org_apache_activemq_Broker_AverageEnqueueTime.sum(['cluster','destinationName','destinationType'])
  # The max time a message was held on this destination.
  - name: max_enqueue_time
    exp: org_apache_activemq_Broker_MaxEnqueueTime.sum(['cluster','destinationName','destinationType'])
  # Number of messages that has been delivered to consumers.
  - name: dispatch_count
    exp: org_apache_activemq_Broker_DispatchCount.sum(['cluster','destinationName','destinationType'])
  # Number of messages that have been expired.
  - name: expired_count
    exp: org_apache_activemq_Broker_ExpiredCount.sum(['cluster','destinationName','destinationType'])
  # Number of messages that have been dispatched to but not acknowledged by consumers.
  - name: inflight_count
    exp: org_apache_activemq_Broker_InFlightCount.sum(['cluster','destinationName','destinationType'])
  # Average message size on this destination.
  - name: average_message_size
    exp: org_apache_activemq_Broker_AverageMessageSize.avg(['cluster','destinationName','destinationType'])
  # Max message size on this destination.
  - name: max_message_size
    exp: org_apache_activemq_Broker_MaxMessageSize.max(['cluster','destinationName','destinationType'])
